package com.basicalg.basicalgorithms;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Hyperlink;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class PanePosition extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        VBox vBox = new VBox();
        vBox.setPadding(new Insets(10.0d));
        vBox.setBackground(new Background(
                new BackgroundFill(Color.BLACK, new CornerRadii(0), new Insets(0))
        ));

        Pane p = new Pane();

        Arc largeArc = new Arc(0,0, 100, 100, 270, 90);
        largeArc.setFill(Color.web("0x59291E"));
        largeArc.setType(ArcType.ROUND);

        Arc backgroundArc = new Arc(0,0,160, 160, 270, 90);
        backgroundArc.setFill(Color.web("0xD96F32"));
        backgroundArc.setType(ArcType.ROUND);

        Arc smArc1 = new Arc(0, 160, 30, 30, 270, 180);
        smArc1.setFill(Color.web("0xF2A444"));
        smArc1.setType(ArcType.ROUND);

        Circle smCircle = new Circle(
                160 /Math.sqrt(2), 160/Math.sqrt(2), 30, Color.web("0xF2A444")
        );

        Arc smArc2 = new Arc(160, 0, 30,30, 180,180);
        smArc2.setFill(Color.web("0xF2A444"));
        smArc2.setType(ArcType.ROUND);

        Hyperlink hyperlink = new Hyperlink("About the App");
        hyperlink.setFont(Font.font(36));
        hyperlink.setTextFill(Color.web("0x3E6C93"));
        hyperlink.setBorder(Border.EMPTY);

        Arc meArc = new Arc(568-20, 320-20, 60, 60, 90, 90);
        meArc.setFill(Color.web("0xD9583B"));
        meArc.setType(ArcType.ROUND);

        p.getChildren().addAll(backgroundArc, largeArc, smArc1, smCircle, smArc2, hyperlink, meArc);
        vBox.getChildren().add(p);

        Scene scene = new Scene(vBox);
        scene.setFill(Color.BLACK);

        primaryStage.setScene(scene);
        primaryStage.setTitle("Pane APP");
        primaryStage.setWidth(568);
        primaryStage.setHeight(320);
        primaryStage.setOnShown((evt) -> {
            hyperlink.setLayoutX(284 - (hyperlink.getWidth()/3));
            hyperlink.setLayoutY(160 - hyperlink.getHeight());
        });
        primaryStage.show();
    }

    public  static void main(String[] args) {
        launch(args);
    }
}

